// import React from 'react';
// import ReactDOM from 'react-dom';

import React from './lib/react';
import ReactDOM from './lib/react-dom';

function TextInput(props, ref) {
  return <input ref={ref} />
}

const ForwardRefTextInput = React.forwardRef(TextInput);

class Form extends React.Component {
  constructor(props) {
    super(props);
    this.input = React.createRef();
  }

  getFocus = (event) => {
    console.log('获取函数组件需要 React.forwardRef 包裹处理')
    this.input.current.focus();
  }

  render() {
    return (
      <div>
        <ForwardRefTextInput ref={this.input}/>
        <button onClick={this.getFocus}>获取焦点</button>
      </div>
    )
  }
}

ReactDOM.render(
  <Form/>,
  document.getElementById('root')
);

// 注意如果要使用老的把 jsx 编译成 React.createElement(), 必须在启动项中设置 cross-env DISABLE_NEW_JSX_TRANSFORM=true
// 如： "start": "cross-env DISABLE_NEW_JSX_TRANSFORM=true react-scripts start",